import React, { createContext, useContext, useState } from 'react'
// import Child from './Child'

const context = createContext(null)

export const Child = () => {
  const value = useContext(context)
  return (
    <div>Child {value.x}</div>
  )
}


export default function UseContextDemo() {
  const [x, setX] = useState(100)

  return (
    <context.Provider value={{x}}>
      <Child></Child>
      <button onClick={() => { setX(x => x + 1) }}>add</button>
    </context.Provider>
  )
}
